package com.cby.leetcode.二叉树.LC104;

import com.cby.leetcode.二叉树.LC617.LC617;

public class LC104 {
    /**
     * 求二叉树最大深度
     * 即求左右子树最大深度 + 1
     * 自下而上递归写法
     * @param args
     */

    public static void main(String[] args){}

    public class TreeNode{
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(){};

        TreeNode(int val,TreeNode left,TreeNode right){
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }

    static class Solution{

        public int MaxDepth(TreeNode root){
            if(root == null)
                return 0;

            int left = MaxDepth(root.left);
            int right = MaxDepth(root.right);

            return Math.max(left,right) + 1;

        }

    }

}
